//
//  BYJManageTableViewCell.m
//  BLDMusics
//
//  Created by 白云杰 on 16/3/22.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "BYJManageTableViewCell.h"

@interface BYJManageTableViewCell ()

/** 歌名 */
@property (nonatomic, retain) UILabel *nameLabel;
/** 歌手名字 */
@property (nonatomic, retain) UILabel *singerLabel;

@end

@implementation BYJManageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)setModel:(BYJsongListModel *)model {
    _model = model;
    [self assignment];
}

- (void)createCell {

    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_nameLabel];
    
    self.singerLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_singerLabel];
    
    self.imgView = [[UIImageView alloc] init];
    [self.contentView addSubview:_imgView];
    _imgView.image = [UIImage imageNamed:@"list_edit_unselected"];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _nameLabel.frame = CGRectMake(20, 10, SCREEN_WIDTH / 2, self.contentView.frame.size.height * 4 / 9);
    
    _singerLabel.frame = CGRectMake(20, self.contentView.frame.size.height * 4 / 9 + 10, SCREEN_WIDTH / 2, self.contentView.frame.size.height * 1 / 3);
    _singerLabel.font = [UIFont systemFontOfSize:12];
    
    _imgView.frame = CGRectMake(SCREEN_WIDTH - 60, 10, 50, 50);
    _imgView.backgroundColor = [UIColor clearColor];

}

- (void)assignment {
    
    _nameLabel.text = _model.name;
    _singerLabel.text = _model.singerName;
    
    if (_model.isSelect) {
        
        _imgView.image = [UIImage imageNamed:@"list_edit_selected"];
    }else {
    
        _imgView.image = [UIImage imageNamed:@"list_edit_unselected"];
    }
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
